package com.shop.shorturl.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @author Song Yinghui
 * @date 2019/12/9
 * @Version 1.0
 */
@Controller
public class ShortUrlController {

    @RequestMapping(value = "/")
    public void shortUrl(HttpServletRequest request , HttpServletResponse response){
        try {
            response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
            response.sendRedirect("https://www.baidu.com");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
